import java.util.*;

/**
 * @author: gao
 * @create-date: 2025/3/12 10:55
 */

public class Main {
    public List<Integer> findSubstring(String s, String[] words){
        List<Integer> ret = new ArrayList<>();
        Map<String,Integer> hash1 = new HashMap<String,Integer>();//保存words里面单词的频次
        for(String str : words) hash1.put(str, hash1.getOrDefault(str,0)+1);//把单词丢进哈希表里面，并单词个数
        int len = words[0].length(),m = words.length;
        for (int i = 0; i < len; i++) {//执行次数
            Map<String,Integer> hash2 = new HashMap<String,Integer>();
            for (int left = i,right = i,count = 0;right + len <= s.length();right += len){//count用来统计有效字符串的个数
                //进窗口与维护count
                String in = s.substring(right,right+len);
                hash2.put(in,hash2.getOrDefault(in,0)+1);
                if(hash2.get(in) <= hash1.getOrDefault(in,0)) count++;
                //判断
                if(right - left + 1 > len * m){
                    //出窗口与维护count
                    String out = s.substring(left,left+len);
                    if(hash2.get(out) <= hash1.getOrDefault(out,0)) count--;
                    hash2.put(out,hash2.get(out) - 1);
                    left += len;
                }
                if(count == m) ret.add(left);
            }
        }
        return ret;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNext()){
            String s = in.nextLine();
            int size = in.nextInt();
            in.nextLine();
            String[] words = new String[size];
            for (int i = 0; i < size; i++) {
                words[i] = in.nextLine();
            }
            Main solution = new Main();
            List<Integer> result = solution.findSubstring(s,words);
            System.out.println(result);
        }
    }
}